package com.itfenghuang.day10;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class A06_Server {
    public static void main(String[] args) throws IOException {
        /**
         * 服务端
         * 创建 ServerSocket
         *      构造方法
         *      public ServerSocket(int part) 指定一个端口号
         *
         */
        // 1. 创建 ServerSocket对象
        ServerSocket ss = new ServerSocket(10086);
        // 2. 监听连接 客户端的连接
        Socket socket = ss.accept();
        // 3. 获取客户端发送的消息
        InputStream is = socket.getInputStream();
        byte[] bys=new byte[1024];
        int len = is.read(bys);
        String s = new String(bys, 0, len);
        System.out.println(s);

        //释放资源
        ss.close();


    }
}
